from dotenv import load_dotenv, find_dotenv
_ = load_dotenv(find_dotenv())

from openai import OpenAI
client = OpenAI()
model = "whisper-1"

while True:  
    file_path = input("请输入音频文件路径名称（输入'exit'退出程序）: ") 
    if file_path is None or file_path == "" :
        continue
    elif file_path.lower() == 'exit':  
        print("程序退出。\n")  
        break 
    else:
        with open(file_path, "rb") as audio_file:
            transcription = client.audio.transcriptions.create(
            model=model, 
            file=audio_file
            )
            print(transcription.text)